import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionDemo1 {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("张磊1");
        c.add("张磊2");
        c.add("张磊3");
        c.add("张磊4");
        // 使用迭代器便利集合
        Iterator<String> iterator = c.iterator();
//        System.out.println(iterator.next());
//        System.out.println(iterator.next());
//        System.out.println(iterator.next());
//        System.out.println(iterator.next());

        while (iterator.hasNext()){         // 循环结合迭代器遍历集合
            String next = iterator.next();
            System.out.println(next);
        }


    }
}
